package com.whz.serial;

import lombok.extern.slf4j.Slf4j;

import java.io.*;
import java.util.Date;

/**
 * @ClassName PeriodMainTest
 * @Description TODO
 * @Author hong-zhi
 * @Date 2021/5/27 10:58
 * @Version 1.0
 */
@Slf4j
public class PeriodMainTest {
    public static void main(String[] args) throws IOException {
        String filePath = "d://period.txt";
        try (ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream(filePath));
             ObjectInputStream ois = new ObjectInputStream(new FileInputStream(filePath))) {
            Period period = new Period(new Date(2021, 4, 27),
                    new Date(2021, 5, 27));

            log.info("period.hashCode(): {}", period.hashCode());
            oos.writeObject(period);
            Object period1 = ois.readObject();
            log.info("period1.hashCode(): {}", period1.hashCode());
        } catch (FileNotFoundException | ClassNotFoundException e) {
            e.printStackTrace();
        }
    }
}
